
ifeq ("$(shell whoami)", "malloy")
  CXX = g++
else
  CXX = g++
endif
CXX_LDFLAG = g++

# Warnings frequently signal eventual errors:
CXXFLAGS=-pg -g `sdl-config --cflags` -W -Wall -Weffc++ -Wextra -pedantic -O0

ifeq ("$(shell uname)", "Darwin")
  LDFLAGS =
else
  ifeq ("$(shell uname)", "Linux")
  LDFLAGS = `sdl-config --libs` -lSDL_ttf -lSDL_image -lSDL_mixer -lexpat -lSDL_gfx -lm
  endif
endif

OBJS = \
	boss.o \
	bossPuppetController.o \
	bullet.o \
	clock.o \
	collisionStrategy.o \
	explodingSprite.o \
	explosion.o \
	explosionFactory.o \
	frame.o \
	gamedata.o \
	gui.o \
	hud.o \
	ioManager.o \
	item.o \
	main.o \
	manager.o \
	multiSprite.o \
	multiSpriteFactory.o \
	orb.o \
	parseXML.o \
	player.o \
	simulator.o \
	sound.o \
	springConstraint.o \
	sprite.o \
	spriteFactory.o \
	spriteManager.o \
	vector2f.o \
	viewport.o \
	world.o

EXEC = run

# $< refers to the first dependency
%.o: %.cpp
	$(CXX) $(CXXFLAGS) -c $< -o $@

# $@ refers to the target
$(EXEC): $(OBJS)
	$(CXX_LDFLAG) $(CXXFLAGS) -o $@ $(OBJS) $(LDFLAGS)

boss.o: boss.cpp boss.h ioManager.h viewport.h spriteManager.h explodingSprite.h hud.h bullet.h utils.h multiSprite.h vector2f.h
bossPuppetController.o: bossPuppetController.cpp bossPuppetController.h puppetController.h puppet.h
bullet.o: bullet.cpp bullet.h sprite.h
clock.o: clock.cpp clock.h
collisionStrategy.o: collisionStrategy.cpp collisionStrategy.h sprite.h ioManager.h
explodingSprite.o: explodingSprite.cpp explodingSprite.h explosion.h ioManager.h explosionFactory.h gamedata.h
explosion.o: explosion.cpp explosion.h gamedata.h sprite.h
explosionFactory.o: explosionFactory.cpp explosionFactory.h factory.h gamedata.h sprite.h
frame.o: frame.cpp frame.h viewport.h ioManager.h
gamedata.o: gamedata.cpp gamedata.h parseXML.h
gui.o: gui.cpp gui.h frame.h ioManager.h parseXML.h vector2f.h viewport.h
hud.o: hud.cpp hud.h gamedata.h ioManager.h player.h
item.o: sprite.h gamedata.h item.cpp item.h
ioManager.o: ioManager.cpp ioManager.h gamedata.h 
main.o: main.cpp manager.h explosionFactory.h
manager.o: manager.cpp manager.h gamedata.h ioManager.h clock.h hud.h gui.h player.h world.h simulator.h spriteFactory.h explosionFactory.h multiSpriteFactory.h sound.h
multiSprite.o: multiSprite.cpp multiSprite.h sprite.h gamedata.h multiSpriteFactory.h clock.h viewport.h
multiSpriteFactory.o: multiSpriteFactory.cpp multiSpriteFactory.h factory.h ioManager.h
orb.o: orb.cpp orb.h sprite.h gamedata.h
parseXML.o: parseXML.cpp parseXML.h
player.o: player.cpp player.h ioManager.h viewport.h spriteManager.h explodingSprite.h hud.h bullet.h utils.h multiSprite.h vector2f.h boss.h sound.h
simulator.o: simulator.h simulator.cpp sprite.h collisionStrategy.h spriteManager.h constraint.h contact.h
sound.o: sound.cpp sound.h
springConstraint.o: springConstraint.cpp springConstraint.h constraint.h
sprite.o: sprite.cpp sprite.h gamedata.h drawable.h frame.h spriteFactory.h
spriteFactory.o: spriteFactory.cpp spriteFactory.h factory.h ioManager.h
spriteManager.o: spriteManager.cpp spriteManager.h sprite.h contact.h player.h item.h drawable.h
vector2f.o: vector2f.cpp vector2f.h
viewport.o: viewport.cpp viewport.h sprite.h gamedata.h ioManager.h
world.o: world.cpp world.h frame.h gamedata.h viewport.h spriteFactory.h

clean:
	rm -rf $(OBJS)
	rm -rf $(EXEC)
	rm -rf gmon.out
